package com.zcc.makingfriend.controller;

import com.zcc.makingfriend.dao.Image;
import com.zcc.makingfriend.service.ImageService;
import com.zcc.makingfriend.untils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zcc
 */
@Api(tags = "图片管理")
@RestController
@RequestMapping("/image")
public class ImageController {
    @Autowired
    ImageService imageService;

    @ApiOperation("新增图片")
    @PostMapping("/add")
    public Result addImage(@RequestBody Image image) {
        int i = imageService.addImage(image);
        if (i == 1) {
            return Result.success("新增图片成功");
        }
        return Result.fail("新增图片失败");
    }

    @ApiOperation("更新图片")
    @PostMapping("/update")
    public Result updateImage(@RequestBody Image image) {
        int i = imageService.updateImage(image);
        if (i == 1) {
            return Result.success("新增图片成功");
        }
        return Result.fail("新增图片失败");
    }
}
